package com.tongji.admin.view
{	
	import com.tongji.admin.event.BrandAdminEvent;
	import com.tongji.admin.model.BrandModel;
	import com.tongji.admin.vo.Brand;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/7/
	 */ 
	public class BrandAdminMediator extends Mediator
	{
		[Inject]
		public var brandModel:BrandModel;
		
		[Inject]
		public var view:BrandAdminView;
		
		override public function onRegister():void
		{
			view.buttonGroup.addBtn.addEventListener(MouseEvent.CLICK, addBrandHandler);
		}
		
		private function addBrandHandler(event:MouseEvent):void
		{
			Alert.show("ok");
			var brand:Brand = new Brand();
			brand.brandCreateDate = new Date();
			brand.brandCreator = "caddy";
			brand.brandDesc = view.brandDescTX.text;
			brand.brandEnglishName = view.brandEnglishNameTX.text;
			brand.brandName = view.brandNameTX.text;
			brand.brandOrder = int(view.brandOrderTX.text);
			
			dispatch(new BrandAdminEvent(BrandAdminEvent.ADD_A_BRAND, brand));
		}
	}
}